package com.kefu.robot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kefu.common.annotation.Permission;
import com.kefu.common.controller.AbstractBaseController;
import com.kefu.common.result.Result;
import com.kefu.common.result.ResultGenerator;
import com.kefu.common.vo.DeleteVo;
import com.kefu.common.vo.DetailVo;
import com.kefu.robot.model.RobotDocNodeItemQuestion;
import com.kefu.robot.service.RobotDocNodeItemQuestionService;
import com.kefu.robot.vo.RobotDocNodeItemQuestionSearchVo;
import com.kefu.robot.vo.RobotDocNodeItemQuestionInsertVo;
import com.kefu.robot.vo.RobotDocNodeItemQuestionUpdateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

/**
 * @author xiaoyu
 * @date 2023/02/24
 */
@RestController
@Api(tags = "多轮问题节点相似问题")
@RequestMapping("robot/itemQuestion")
public class RobotDocNodeItemQuestionController extends AbstractBaseController {

    @Autowired
    private RobotDocNodeItemQuestionService robotDocNodeItemQuestionService;

    @PostMapping("/add")
    @ApiOperation(value = "批量新增多轮问题节点相似问题")
    public Result<String> add(@Validated @RequestBody RobotDocNodeItemQuestionInsertVo robotDocNodeItemQuestionInsertVo) {
        logger.info("新增多轮问题节点相似问题:{}", robotDocNodeItemQuestionInsertVo);

        robotDocNodeItemQuestionService.addRobotDocNodeItemQuestion(robotDocNodeItemQuestionInsertVo);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除多轮问题节点相似问题")
    public Result<String> delete(@Validated @RequestBody DeleteVo delete) {
        logger.info("删除多轮问题节点相似问题:{}", delete);

        robotDocNodeItemQuestionService.removeById(delete.getId());
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改多轮问题节点相似问题")
    public Result<String> update(@Validated @RequestBody RobotDocNodeItemQuestionUpdateVo robotDocNodeItemQuestionUpdateVo) {
        logger.info("修改多轮问题节点相似问题:{}", robotDocNodeItemQuestionUpdateVo);

        robotDocNodeItemQuestionService.updateIteamQuestion(robotDocNodeItemQuestionUpdateVo);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/detail")
    @ApiOperation(value = "多轮问题节点相似问题详情")
    public Result<List<RobotDocNodeItemQuestion>> detail(@Validated @RequestBody DetailVo detail) {

        List<RobotDocNodeItemQuestion> robotDocNodeItemQuestions = robotDocNodeItemQuestionService.ItemQuestionDatialByItemId(detail.getId());
        return ResultGenerator.genSuccessResult(robotDocNodeItemQuestions);
    }

//    @PostMapping("/list")
//    @ApiOperation(value = "查询多轮问题节点item相似问题")
//    public Result<Page<RobotDocNodeItemQuestion>> list(@Validated @RequestBody RobotDocNodeItemQuestionSearchVo search) {
//
//        Page<RobotDocNodeItemQuestion> page = robotDocNodeItemQuestionService.searchLambdaPage(search);
//        return ResultGenerator.genSuccessResult(page);
//    }
}
